package com.atcx.dateconver;

import org.springframework.core.convert.converter.Converter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * Copyright (C), 2017-2022, MIDOU
 * ClassName: DateConver
 * Author:   pangshu
 * Date:     2022/7/21 18:18
 * Version: 1.0
 * Description:日期进行转换
 */
@Component
public class DateConver implements Converter<String, LocalDateTime> {

    @Override
    public LocalDateTime convert(String source) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime time = null;
        LocalDateTime parse = LocalDateTime.parse(source, formatter);
        return parse;
    }
}
